<template>
	<gui-page ref="guiPage" :customHeader="true">
		<template v-slot:gHeader>
			<nav-bar-custom left-icon="left" :leftType="'1'" @clickLeftBack="clickLeftBack"
				:title="$t('consumo.interOrgTransferIn')" @clickRight="clickRight" scanType="1"></nav-bar-custom>
		</template>
		<template v-slot:gBody>
			<view class="page-auto-noheight paddingbottom">
				<!-- 调拨单信息 -->
				<view class="custom-form-card">
					<view class="custom-card-title">
						<text class="title-line"></text>
						{{ $t('distributedOut.informationOut') }}
					</view>
					<view class="custom-card-itemOne">
						<text class="item-info-title">{{ $t('distributedEnter.distributed') }}：</text>{{
							data.enterDetails.receiptCode }}
					</view>
					<view class="custom-card-itemOne">
						<text class="item-info-title">{{ $t('distributedEnter.date') }}：</text>{{
							data.enterDetails.receiptDate }}
					</view>
					<view class="custom-card-itemOne">
						<text class="item-info-title">{{ $t('distributedEnter.transferOutQty') }}：</text>{{
							data.enterDetails.outSumQty }}
					</view>
					<view class="custom-card-itemOne">
						<text class="item-info-title">{{ $t('pageTranslation.qtyTransferred') }}：</text>{{
							data.enterDetails.inSumQty }}
					</view>
					<view class="custom-card-itemOne">
						<text class="item-info-title">{{ $t('distributedEnter.surplusQty') }}：</text>{{
							data.enterDetails.surplusQty }}
					</view>
					<view class="custom-card-itemOne">
						<text class="item-info-title">{{ $t('distributedEnter.scannedQuantity') }}：</text>{{
							totalScanNum|| 0 }}
					</view>
				</view>
				<!-- 扫描条码 -->
				<view class="custom-form-card">
					<view class="custom-card-title">
						<text class="title-line"></text>
						{{ $t('distributedEnter.barcodeScan') }}
					</view>
					<view class="custom-card-itemTwo">
						<text class="item-info-title"><text class="required-color">*</text>{{
							$t('distributedOut.warehouse') }}：</text>
						<superweiCombox style="text-align: right;" :candidates="data.organizationEnterList"
							:placeholder="$t('distributedOut.placeholder')" :isJSON="true" keyName="value"
							v-model="data.selectId" @select="selectOut"></superweiCombox>
					</view>
					<view class="custom-card-itemTwo" style="padding: 10rpx 0;">
						<text class="item-info-title"><text class="required-color">*</text>{{
							$t('distributedOut.location') }}：</text>
						<storageBin :ignoreLocationCode="data.ignoreLocationCode" class="gui-text-right"
							requestUrl="/wms/wmsLocationCapacity/getLocationByWarehouseCodeForCCP"
							:requestParam="data.requestParam" :locationUseList="data.locationUseList"
							@setClick="getClick"></storageBin>
					</view>
					<view class="custom-card-scan" style="margin-top:20rpx;">
						<uni-easyinput class="uni-mt-5" suffixIcon="scan" v-model="data.barcode"
							:placeholder="$t('stockManage.pleaseScanCode')" type="search" @confirm="confirm"
							@iconClick="iconClick">
						</uni-easyinput>
					</view>
				</view>
				<!-- 当前扫描条码 -->
				<view class="custom-form-card" v-if="data.currentBarcode">
					<uni-collapse v-model="data.value">
						<uni-collapse-item titleBorder="none" :show-animation="true">
							<template v-slot:title>
								<view class="custom-card-title">
									<text class="title-line"></text>
									{{ $t('distributedOut.atPresent') }}
								</view>
							</template>
							<view class="content">
								<view class="custom-card-itemOne">
									<text class="item-info-title">{{ $t('distributedEnter.materialCoded') }}：</text>{{
										data.currentBarcode.barcode
									}}
								</view>
								<view class="custom-card-itemOne">
									<text class="item-info-title">{{ $t('distributedEnter.materialSpec') }}：</text>{{
										data.currentBarcode.materialSpec }}
								</view>
								<view class="custom-card-itemOne">
									<text class="item-info-title">{{ $t('distributedEnter.materialCode') }}：</text>{{
										data.currentBarcode.materialCode }}
								</view>
								<view class="custom-card-itemOne">
									<text class="item-info-title">{{ $t('distributedEnter.materialName') }}：</text>{{
										data.currentBarcode.materialName }}
								</view>
								<view class="custom-card-itemOne">
									<view class="card-item-50">
										<text class="item-info-title">{{ $t('distributedEnter.qty') }}：</text>{{
											data.currentBarcode.currentQty }}
									</view>
									<view class="card-item-50">
										<text class="item-info-title">{{ $t('distributedEnter.uom') }}：</text>{{
											data.currentBarcode.unit }}
									</view>
								</view>
								<view class="custom-card-itemOne">
									<text class="item-info-title">{{ $t('distributedOut.organizationOut') }}：</text>{{
										data.currentBarcode.barcode
											? '国内' : '' }}
								</view>
								<view class="custom-card-itemOne">
									<text class="item-info-title">{{ $t('distributedOut.organizationIn') }}：</text>{{
										data.currentBarcode.barcode
											? '美国' : '' }}
								</view>
							</view>
						</uni-collapse-item>
					</uni-collapse>
				</view>
				<view class="gui-flex gui-rows gui-nowrap gui-align-items-center gui-margin-top">
					<view class="gui-title-line"></view>
					<text class="gui-primary-text gui-h6" style="padding-left:50rpx; padding-right:50rpx;">{{
						$t('materials.distributedManner') }}</text>
					<view class="gui-title-line"></view>
				</view>
				<uni-card class="element-auto gui-margin-top card-my">
					<view class="element-auto" style="height: 300rpx">
						<zb-table :columns="data.column1" :stripe="true" @rowClick="rowClick" :border="true"
							:data="tableData.list" @customLook="customBtnFn" :cell-style="cellStyle"
							:cell-header-style="cellHeaderStyle">
						</zb-table>
					</view>
				</uni-card>
				<!-- 底部操作栏 -->
				<view class="page-bottom-box bottom-postion">
					<view class="page-bottomBtn bottomBtn-bgcolor-green" @click="submit">
						{{ $t('calendar.submit') }}
					</view>
				</view>
			</view>
			<!-- 普通弹窗 -->
			<uni-popup ref="popup" type="center">
				<view class="input-dialog-box"
					style="padding: 40rpx 20rpx 20rpx 20rpx;border-radius: 22rpx;width: 600rpx;">
					<uni-icons class="popup-close-icons" type="closeempty" color="#9C9C9C" size="26"
						@click="closePopup"></uni-icons>
					<view class="custom-card-itemOne">
						<text class="item-info-title">{{ $t('distributedEnter.materialCoded') }}：</text>{{data.popupInfo.materialCode }}
					</view>
					<view class="custom-card-itemOne">
						<text class="item-info-title">{{ $t('distributedEnter.materialName') }}：</text>{{data.popupInfo.materialName }}
					</view>
					<view class="custom-card-itemOne">
						<text class="item-info-title">{{ $t('distributedEnter.materialSpec') }}：</text>{{data.popupInfo.materialSpec }}
					</view>
					<view class="custom-card-itemOne">
						<text class="item-info-title">{{ $t('distributedEnter.uom') }}：</text>{{ data.popupInfo.unit }}
					</view>
					<view class="custom-card-itemOne">
						<text class="item-info-title">{{ $t('distributedEnter.overallQty') }}：</text>{{data.popupInfo.qty }}
					</view>
					<view class="custom-card-itemOne">
						<text class="item-info-title">{{ $t('materials.quantityInStorage') }}：</text>{{data.popupInfo.scanQty }}
					</view>
					<view class="custom-card-itemOne">
						<text class="item-info-title">{{ $t('JsInternational.onWay') }}：</text>{{data.popupInfo.totalPathLossNum }}
					</view>
					<view class="custom-card-itemOne">
						<text class="item-info-title">{{ $t('distributedEnter.scannedQuantity') }}：</text>{{data.popupInfo.currentScanQty }}
					</view>
				</view>
			</uni-popup>
		</template>
	</gui-page>
</template>

<script setup>
import {navigate,navigateBack} from '@/utils/routerSkip.js';
import {reactive,ref,onMounted,computed,watch,toRaw,toRef} from 'vue';
import {getDataDictionaryFn,pitchOnFn,sortClass} from '@/utils/index.js'
import {findStepoutHById,selectWmsBarcodeInfoWms,distributedCallIn} from '@/api/api.js'
import superweiCombox from '@/components/superweiCombox';
import tableColor from '@/hooks/tableColor.js'
import storageBin from '@/components/storageBin.vue'
import {basPdaOperationLogFn} from '@/utils/index.js';
import {OPERATION_SCAN,OPERATION_LOOK,OPERATION_COMMIT} from '@/constant/index.js'
import {useStore} from "vuex";
import {onBackPress} from '@dcloudio/uni-app';
import pdaScan from '@/hooks/pdaScan.js'

//国际化引入
import {useI18n} from 'vue-i18n';
const {t} = useI18n();

let store = useStore()
const {scan} = pdaScan()
components: {
	storageBin,
		superweiCombox
}
let {tableData} = tableColor();
const {cellStyle,cellHeaderStyle} = tableColor();

const props = defineProps({
	id: String
})
let popup = ref(null)
let inputDialog = ref(null)
let data = reactive({
	value: ['0'],
	selectedText: '',
	selectId: '',
	organizationEnterList: [],
	locationId: '',
	currentLocationInfo: {}, //当前选中库位信息
	barcode: '',
	column1: [{
		name: 'age',
		type: 'ailibtn',
		label: t('translationImage.operation'),
		scanValue: '',
		fixed: true,
		width: 80,
	},
	{
		name: 'materialCode',
		label: t('distributedEnter.materialCode'),
		fixed: true,
		width: 100,
		emptyString: '--'
	},
	{
		name: 'materialName',
		label: t('distributedEnter.materialName'),
	},
	{
		name: 'materialSpec',
		label: t('distributedEnter.materialSpec'),
		width: 200,
	},
	{
		name: 'unit',
		label: t('distributedEnter.uom'),
		width: 60,
	},
	{
		name: 'qty',
		label: t('distributedEnter.overallQty'),
		width: 60,
	},
	{
		name: 'scanQty',
		label: t('materials.quantityInStorage'),
		width: 100,
	},
	{
		name: 'currentScanQty',
		label: t('distributedEnter.scannedQuantity'),
		width: 120,
	},],
	requestParam: {
		warehouseCode: 'RM'
	},
	ignoreLocationCode: [], //前端算满的库位
	enterDetails: {},
	currentBarcode: {}, //当前barcode
	locationUseList: [
		// {
		// 	locationCode:'', //库位code
		// 	surplusCapacity:0, //后端告诉前端容量
		// 	barcodeList:[], //当前库位本次扫描绑定的barcode条码集合
		// 	currentCapacity:0, //后端容量减去本次扫描绑定条码的剩余容量  前端预算容量
		// }
	], //当前用户使用库位情况
	popupInfo: {}, //当前行的弹窗信息
	doubleArray: {} //物料纬度的barcode条码
})


data.barcodeList = computed(() => {
	return store.state.transferredList
})

const totalScanNum = computed(() => {
	let total = 0;
	data.barcodeList.forEach(x => {
		total += Number(x.currentQty)
	})
	return total
})

//计算剩余数量
watch(() => data.barcodeList, (newval, oldval) => {
	//计算剩余数量
	const scanNum = totalScanNum.value || 0
	data.enterDetails.surplusQty = (Number(data.enterDetails.outSumQty) - Number(data.enterDetails.inSumQty) -
		Number(scanNum)).toFixed(4)
}, {
	immediate: true,
	deep: true
})

//整个调入单的途损数量
data.oddTotalPathLossNum = computed(() => {
	let total = 0
	tableData.list.forEach(x => {
		total += x.totalPathLossNum
	})
	return total
})

// 计算库位逻辑
const calculateLocationCode = (newVal) => {
	let tepData = toRaw(newVal)
	// 先清空,后续追加
	data.locationUseList.forEach(l => {
		l.barcodeList = []
	})
	// 追加
	tepData.forEach(x => {
		data.locationUseList.forEach(k => {
			if (x.locationCode == k.locationCode) {
				k.barcodeList.push(x.barcode)
				k.surplusCapacity = k.currentCapacity - k.barcodeList.length
			}
		})
	})
	//算满库位变量置空
	data.ignoreLocationCode = []
	// 把前端预算容量算出为0的库位抽出
	data.locationUseList.forEach(x => {
		if (x.surplusCapacity == 0) {
			data.ignoreLocationCode.push(x.locationCode)
		}
	})
}

function f(a, b) { //排序函数
	return (b.id - a.id); //返回比较参数
}

//把扫描条码变为物料集合的二维数组
watch(() => data.barcodeList, (newVal, oldVal) => {
	let tepData = toRaw(newVal)
	let list = sortClass(tepData)
	let tepList = []
	if (list.length) {
		list.forEach(x => {
			let item = {
				child: [],
				currentQty: 0,
				totalPathLossNum: 0
			}
			x.forEach(k => {
				item.materialCode = k.materialCode
				item.materialName = k.materialName
				item.materialSpec = k.materialSpec
				item.unit = k.unit
				item.currentQty = Number(item.currentQty) + Number(k.currentQty)
				item.totalPathLossNum += Number(k.pathLossNum)
				item.isContinue = true
				item.child.push(k)
			})
			tepList.push(item)
		});
		tableData.list.sort(f); //这一步是进行排序	
		tableData.list.map((item, index) => {
			if (item.materialCode == data.currentBarcode.materialCode) {
				tableData.list.unshift(tableData.list.splice(index, 1)[0]);
			}
		})
		var sortArr = []
		tableData.list.forEach(x => {
			if (sortArr.some(m => m.materialCode == x.materialCode)) {
			}
			else {
				sortArr.push(x)
			}
		})
		tableData.list.forEach(x => {
			tepList.forEach(k => {
				if (k.materialCode == x.materialCode && k.isContinue == true) {
					let outQty = x.qty //调出数量
					let inQty = x.scanQty //已调入数量
					let leaveQty = Number(outQty - inQty) - x.currentScanQty
					let canAllowQty = 0;
					if (sortArr.some(m => m.id == x.id)) {
						x.totalPathLossNum = k.totalPathLossNum
					}
					if (leaveQty == 0) {
						k.currentQty -= Number(x.currentScanQty) //这里需要减去已经分配的
					} else if (leaveQty >= k.currentQty) {
						canAllowQty = k.currentQty
						tepList.forEach(h => {
							if (h.materialCode == k.materialCode) {
								k.isContinue = false;
							}
						})
						x.currentScanQty = Number(canAllowQty)
						k.currentQty -= x.currentScanQty //这里需要减去已经分配的
					} else {
						var cqty = k.currentQty - (x.currentScanQty)
						if (cqty <= leaveQty) {
							canAllowQty = Number(cqty)
						}
						else {
							canAllowQty = Number(leaveQty)
						}
						tepList.forEach(h => {
							if (h.materialCode == k.materialCode) {
								k.isContinue = true;
							}
						})
						x.currentScanQty += Number(canAllowQty)
						k.currentQty -= Number(x.currentScanQty) //这里需要减去已经分配的
					}
				}

			})
		})

		data.doubleArray = tepList;
	} else {
		tableData.list.forEach(x => {
			x.currentScanQty = 0
			x.totalPathLossNum = 0
		})
		data.currentBarcode = null
	}

	calculateLocationCode(newVal)

}, {
	immediate: true,
	deep: true
});

onMounted(() => {
	uni.$on('scancodedate', (res) => {
		console.log('获取到的code：' + res.code)
		getCode(res.code, 'pda')
	})
	getInitData();
	findStepoutHByIdFn()
})

// 根据id查询调入单详情
const findStepoutHByIdFn = () => {
	let parmes = {
		id: props.id
	}
	findStepoutHById(parmes).then(res => {
		try {
			let inputParameter = JSON.stringify(parmes)
			let returnParameter = JSON.stringify(res)
			let operationPicture = '组织间调入'
			let callInterface = res.rquestUrl
			let opertionParmes = {
				inputParameter,
				returnParameter,
				operationPicture,
				callInterface,
				responseCode: res.status, //返回状态
				errorMessage: res.message, //错误信息
				isPass: res.status == 200 ? 'Y' : 'N', //是否成功 Y N
				operationType: OPERATION_LOOK
			}
			basPdaOperationLogFn(opertionParmes)
		} catch (error) { }
		if (res.status == 200) {
			data.enterDetails = res.data;
			//计算剩余数量
			const scanNum = totalScanNum.value || 0
			data.enterDetails.surplusQty = (Number(data.enterDetails.outSumQty) - Number(data.enterDetails
				.inSumQty) - Number(scanNum)).toFixed(4)
			tableData.list = res.data.materials;
			tableData.list?.forEach(x => {
				x.currentScanQty = 0
				x.pathLossNum = 0
				x.totalPathLossNum = 0
			})
		} else {
			uni.showToast({
				title: res.message,
				icon: 'none'
			})
		}
	})
}

const getInitData = async () => {
	// 获取调入组织信息
	data.organizationEnterList = await getDataDictionaryFn('PDATransferInto')
	let tepSelect1 = pitchOnFn(data.organizationEnterList)
	data.selectedText = tepSelect1[0].text
	data.selectId = tepSelect1[0].value
}

// 用户调起相机扫码
const iconClick = async (type) => {
	console.log(type)
	if (type === 'suffix') {
		let code = await scan()
		getCode(code, 'scan')
	}
}
// 用户点击搜索
const confirm = () => {
	getCode(data.barcode, 'keydown')
}
// 获取code
const getCode = (code, type) => {
	// 判断这个托盘本次有没有绑定过
	let isBind = data.barcodeList.some(x => x.barcode == code);
	if (isBind) {
		uni.showToast({
			title: t('JsInternational.scanned'),
			icon: 'none'
		})
		return
	}
	if (!data.selectId) {
		uni.showToast({
			title: t('pageTranslation.plsChooseWarehous'),
			icon: 'none'
		})
		return
	}
	if (!data.locationId) {
		uni.showToast({
			title: t('pageTranslation.plsChooseLocatoinFirstly'),
			icon: 'none'
		})
		return
	}
	// 判断当前用户选择的库位有没有容量
	if (data.ignoreLocationCode.includes(data.locationId)) {
		uni.showToast({
			title: t('JsInternational.volumn'),
			icon: 'none'
		})
		return
	}
	if (!code) {
		uni.showToast({
			title: t('stockManage.pleaseScanCode'),
			icon: 'none'
		})
		return
	}
	let parmes = {
		barcode: code,
		selectType: 'stepIn',
		stepOutNo: data.enterDetails.receiptCode
	}
	selectWmsBarcodeInfoWms(parmes).then(res => {
		try {
			let inputParameter = JSON.stringify(parmes)
			let returnParameter = JSON.stringify(res)
			let operationPicture = '组织间调入'
			let callInterface = res.rquestUrl
			let opertionParmes = {
				inputParameter,
				returnParameter,
				operationPicture,
				callInterface,
				responseCode: res.status, //返回状态
				errorMessage: res.message, //错误信息
				isPass: res.status == 200 ? 'Y' : 'N', //是否成功 Y N
				operationType: OPERATION_SCAN
			}
			basPdaOperationLogFn(opertionParmes)
		} catch (error) { }
		console.log(res)
		if (res.status == 200) {
			// 判断该条码对应的单据还剩多少数量
			let tep = tableData.list.filter(x => x.materialCode == res.data.materialCode);
			console.log(tep)
			let bool = tableData.list.some((item) => {
				return item.materialCode == res.data.materialCode
			})
			if (!bool) {
				uni.showToast({
					title: t('materials.materialIsNot'),
					icon: "none"
				});
				return
			}

			var sumoutQty = 0;
			var inQtyQty = 0;
			var sumScanQty = 0;
			if (tep.length) {
				for (var i = 0; i < tep.length; i++) {
					sumoutQty += tep[i].outQty
					inQtyQty += tep[i].inQty
					sumScanQty += tep[i].currentScanQty
				}

				// 筛选出和当前扫码一直的物料并提位
				if (tableData.list.length && tableData.list.length != 1) {
					for (var i = 0; i < tableData.list.length; i++) {
						var item = {}
						if (tableData.list[i].materialCode === res.data.materialCode) {
							item = tableData.list[i]
							tableData.list.splice(i, 1);
							tableData.list.unshift(item)
							break;
						}
					}
				}
				let num = Number(sumoutQty) - Number(inQtyQty) - Number(sumScanQty); //

				console.log(sumoutQty, '1')
				console.log(inQtyQty, '2')
				console.log(sumScanQty, '3')
				console.log(num, '还剩多少')
				console.log(num - res.data.currentQty, '剩余减去当前扫描条码数量')
				if (num < 0) return uni.showToast({
					title: t('JsInternational.stockIn'),
					icon: 'none'
				})
				if (num - res.data.currentQty < 0) return uni.showToast({
					title: t('JsInternational.receiptStock'),
					icon: 'none'
				})
			}
			data.currentBarcode = res.data;
			data.currentBarcode.inputCurrentQty = data.currentBarcode.currentQty;
			data.currentBarcode.pathLossNum = 0;
			data.currentBarcode.locationCode = data.locationId;
			data.currentBarcode.warehouseId = data.selectId;
			data.currentBarcode.warehouseText = data.selectedText;
			// inputDialog.value.open();
			// 不用弹框去修改数量，直接默认扫描条码的全部数量
			let isTrue = data.locationUseList.some(x => x.locationCode === data.locationId)
			if (!isTrue) {
				data.locationUseList.push({
					locationCode: data.currentLocationInfo.locationCode, //库位code
					surplusCapacity: Number(data.currentLocationInfo.maxCapacity) - Number(data.currentLocationInfo
						.usedInventory), //后端告诉前端容量
					barcodeList: [], //当前库位本次扫描绑定的barcode条码集合
					currentCapacity: Number(data.currentLocationInfo.maxCapacity) - Number(data.currentLocationInfo
						.usedInventory), //后端容量减去本次扫描绑定条码的剩余容量  前端预算容量
				})
			}
			// data.currentBarcode.currentQty = data.currentBarcode.inputCurrentQty;
			store.commit('addTransferredList', data.currentBarcode)
		} else {
			uni.showToast({
				title: res.message,
				icon: 'none'
			})
		}
	})
}

// 获取选中的库位id
const getClick = (x) => {
	console.log(x)
	data.currentLocationInfo = x;
	data.locationId = x.locationCode;
}
const selectOut = (e) => {
	console.log(e)
	data.selectId = e.value;
	data.selectedText = e.text;
}

const customBtnFn = (item, index) => {
	console.log(item, index)
	data.popupInfo = item;
	popup.value.open()
}
const closePopup = () => {
	popup.value.close()
}
const rowClick = () => {

}


// 提交
const submit = () => {
	if (!data.doubleArray.length) {
		uni.showToast({
			title: t('distributedOut.pleaseMaterial'),
			icon: 'none'
		});
		return
	}
	let stepInBarcodes = [];
	console.log(data.doubleArray, 'data.doubleArraydata.doubleArraydata.doubleArray');
	let arry = []
	data.doubleArray.forEach(x => {
		let item = {
			materialCode: x.materialCode,
			barcodeInfoVos: []
		}
		x.child.forEach(k => {
			item.barcodeInfoVos.push({
				barcode: k.barcode,
				id: k.id,
				qty: k.inputCurrentQty,
				numberOfLosses: k.pathLossNum,
				warehouseCode: k.warehouseId,
				locationCode: k.locationCode,
			})
		})
		arry.push(item)
	})
	let parmes = {
		id: props.id,
		docNo: data.enterDetails.receiptCode,
		stepInBarcodes: arry
	}

	// 添加加载框
	uni.showLoading({
		title: 'loading',
		mask: true
	});
	distributedCallIn(parmes).then(res => {
		try {
			let inputParameter = JSON.stringify(parmes)
			let returnParameter = JSON.stringify(res)
			let operationPicture = '组织间调入'
			let callInterface = res.rquestUrl
			let opertionParmes = {
				inputParameter,
				returnParameter,
				operationPicture,
				callInterface,
				responseCode: res.status, //返回状态
				errorMessage: res.message, //错误信息
				isPass: res.status == 200 ? 'Y' : 'N', //是否成功 Y N
				operationType: OPERATION_COMMIT
			}
			basPdaOperationLogFn(opertionParmes)
		} catch (error) { }
		if (res.status == 200) {
			//隐藏加载框
			uni.hideLoading();
			uni.showToast({
				title: t('smashRemoval.submitSuccessfully'),
				icon: 'none'
			});
			store.commit('clearTransferredList')
			setTimeout(() => {
				uni.navigateBack()
			})
		} else {
			uni.showToast({
				title: res.message,
				icon: 'none'
			})
		}
	})
}


// 扫描记录
const clickRight = () => {
	navigate({
		url: '/pages/distributed/enterSweepRecord'
	})
}
// 返回 
onBackPress((options) => {
	if (options.from == 'backbutton') {
		navBackCheck()
		return true;
	}
})
//导航栏左侧返回
const clickLeftBack = () => {
	navBackCheck()
}
const navBackCheck = () => {
	if (!data.barcodeList.length) {
		uni.navigateBack({
			delta: 1
		});
		return true
	}
	uni.showModal({
		title: t('smashRemoval.warmPrompt'),
		content: t('materials.unsubmittedDataIn'),
		success: function (res) {
			if (res.confirm) {
				store.commit('clearTransferredList')
				uni.navigateBack({
					delta: 1
				});
			} else if (res.cancel) {
				console.log('用户点击取消');
			}
		}
	});
}
</script>

<style scoped lang="scss"></style>
